﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using MyMusicList.DBModel;
using Nancy.Json;
using Newtonsoft.Json;
using Tool;

namespace MyMusicList.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class User_OperationsController : ApiController
    {
        private DataDBContext _context;
        BLL.Sys_Music sys_Music = null;
        BLL.User_Music User_Music = null;
        BLL.User User = null;
        public User_OperationsController(DataDBContext context)
        {
            _context = context;
        }

        [HttpGet("getSys_Music")]
        public object getSys_Music(DBModel.Sys_Music value)
        {
            DBModel.User_Music user_Music = new User_Music();
            user_Music.User_Music_name = value.Sys_Music_name;
            user_Music.Sys_Music_Id = value.Sys_Music_Id;
            user_Music.Path = value.Path;

            //模拟php的验证成功
            User_Music = new BLL.User_Music(_context);
            var data = User_Music.post(user_Music);
            if (data.Equals(false))
            {
                return ResultArray(data);
            }
            return ResultArray(data);

        }

        //[Route("api/[controller]/userLogin")]
        [HttpPost("UserLogin")]
        //[Route("[action]")]
        //public string UserLogin()
        public object UserLogin(DBModel.User value)
         {
            //下面为vue的axois
            //var data1 = Request.Form.ToList();
            //var data11 = Request.Form["code"];
            //var data12 = Request.Form["data[code]"];
            //var data13 = Request.Form["data"];

            //var info1 = data1[0].Key;
            //var info2 = data1[0].Value;

            //var info3 = data1.Where(x=>x.Key== "data[code]").FirstOrDefault();

            //var info4 = info3.Value;

            //var data2 = Request.Query["data"];
            //return data1;

            //string User_Name = Request.Form["User_Name"];
            //string Password = Request.Form["Password"];

            //DBModel.User value = new DBModel.User();
            //value.User_Name = User_Name;
            //value.Password = Password;

             //User = new BLL.User(_context);
            var data = User.login(value);
            if (data.Equals(false))
            {
                return ResultArray(data);
            }
            return ResultArray(data);
        }

    }

    public class info
    {
        public string code { set; get; }

        public string name { set; get; }
    }
}